package com.shark;

import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @auther shark
 * @create 2024-08-08 17:43
 */
@SpringBootTest
public class RabbitMQTest4Limit
{
    // 注入 RabbitTemplate 执行
    @Resource
    private RabbitTemplate rabbitTemplate;


    /**
     *     生产者发送100条，演示消费端消息确认+限流
     *
     *         - Ready表示已经发送到队列的消息数量
     *         - Unacked表示已经发送到消费端但是消费端尚未返回ACK信息的消息数量
     *         - Total未被删除的消息总数
     *
     public static final String EXCHANGE_DIRECT = "exchange.direct.order"; //exchange.direct.order
     public static final String QUEUE_NAME  = "queue.order";
     public static final String ROUTING_KEY = "orderlimit";
     */
    @Test
    public void testSendMessageConsumerLimit() {
        for (int i = 1; i <= 70; i++) {
            rabbitTemplate.convertAndSend(
                    "exchange.direct.order",
                    "orderlimit",
                    "Hello atguigu limit msg "+i);
        }

    }
}
